class MyGroovy2 {}

def myGroovy = new MyGroovy2()

// 给实例的 metaclass 添加新特性
myGroovy.metaClass.myProp = 'MyGroovy prop'
myGroovy.metaClass.test = { "xxx>>>$myProp" }

try {
	new MyGroovy2().test()
	assert false, "不会执行"
} catch(e) {
	/* handle error */
}

assert 'xxx>>>MyGroovy prop' == myGroovy.test()
